# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-08-23
# @File : 1_hook_Query_map.py

import frida
import sys

str_host = "127.0.0.1:8877"
manager = frida.get_device_manager()
rdev = manager.add_remote_device(str_host)
pid = rdev.spawn("cn.soulapp.android")
session = rdev.attach(pid)

scr = """
function hook_RegisterNatives() {
    Java.perform(function () {
        var c1 = Java.use("cn.soulapp.android.component.square.recommend.c1");
        c1.$init.implementation = function (timeLineFragment, map, z11) {
            console.log("----------Hook开始了-----------")
            console.log("这是参数timeLineFragment:",timeLineFragment);
            console.log("这是参数map:",map);
            console.log("这是参数z11:",z11);
            var res = this;
            console.log(res);
        };
    });
}

setImmediate(hook_RegisterNatives);
"""
script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
rdev.resume(pid)
sys.stdin.read()
